package com.feinno.urcs.group.interop.service.util;

/**
 * @author Li.Hongbo <lihongbo@feinno.com>
 */
public class FetionMessageType {


	public static String getFetionMessageFileType(String fileName) {
		fileName = null == fileName ? "" : fileName.toLowerCase();
		if (fileName.endsWith("mp4") || fileName.endsWith("avi") || fileName.endsWith("mpeg")) {
			return "VIDEO";
		} else if (fileName.endsWith("amr") || fileName.endsWith("mp3") || fileName.endsWith("wav")) {
			return "AUDIO";
		} else if (fileName.endsWith("jpeg") || fileName.endsWith("gif") || fileName.endsWith("bmp") || fileName.endsWith("png") || fileName.endsWith("jpg")) {
			return "IMG";
		} else if (fileName.endsWith("vcf")) {
			return "PHONE_CARD";
		} else if (fileName.endsWith("location.xml")) {
			return "LOCATION";
		} else {
			return null;
		}
	}


	public static String getFetionMessageContentType(String fileName) {
		fileName = null == fileName ? "" : fileName.toLowerCase();
		if (fileName.endsWith("mp4") || fileName.endsWith("avi") || fileName.endsWith("mpeg")) {
			return "text/video";
		} else if (fileName.endsWith("amr") || fileName.endsWith("mp3") || fileName.endsWith("wav")) {
			return "text/audio";
		} else if (fileName.endsWith("jpeg") || fileName.endsWith("gif") || fileName.endsWith("bmp") || fileName.endsWith("png") || fileName.endsWith("jpg")) {
			return "text/pic";
		} else if (fileName.endsWith("vcf")) {
			return "text/card";
		} else if (fileName.endsWith("location.xml")) {
			return "text/location";
		} else {
			return null;
		}
	}

	public static String getFetionMessageFileTypeFromContentType(String contentType) {
		if ("text/video".equals(contentType)) {
			return "VIDEO";
		} else if ("text/audio".equals(contentType)) {
			return "AUDIO";
		} else if ("text/pic".equals(contentType)) {
			return "IMG";
		} else if ("text/card".equals(contentType)) {
			return "PHONE_CARD";
		} else if ("text/location".equals(contentType)) {
			return "LOCATION";
		} else {
			return null;
		}
	}
}
